import unittest
import route

class RouteTest(unittest.TestCase):
    """Test case for the 'route' module"""
    def setUp(self):
        self.default = route.Route()
        self.route5 = route.Route(5)
    
    def test_cost(self):
        self.assertEqual(self.default.get_cost(), 0)
        self.assertEqual(self.route5.get_cost(), 5)
        
        route_a = route.Route()
        
        for i in range(-50, 50):
            route_a.set_cost(i)
            self.assertEqual(i, route_a.get_cost())
        
    def test_rand_cost(self):
        route_a = route.Route()
        
        for i in range(100):
            route_a.rand_cost()
            self.assertTrue(route_a.get_cost() >= 0)
            self.assertTrue(route_a.get_cost() < 100)
        for i in range(100):
            route_a.rand_cost(min = 30)
            self.assertTrue(route_a.get_cost() >= 30)
            self.assertTrue(route_a.get_cost() < 100)
        for i in range(100):
            route_a.rand_cost(max = 30)
            self.assertTrue(route_a.get_cost() >= 0)
            self.assertTrue(route_a.get_cost() < 30)
        for i in range(100):
            route_a.rand_cost(30, 80)
            self.assertTrue(route_a.get_cost() >= 30)
            self.assertTrue(route_a.get_cost() < 80)
    
    
    def test_rand_poly(self):
        route_a = route.Route()
        
        for i in range(100):
            route_a.rand_cost_poly()
            self.assertTrue(route_a.get_cost() >= 0)
            self.assertTrue(route_a.get_cost() < 100)
        
        for i in range(100):
            route_a.rand_cost_poly(2)
            self.assertTrue(route_a.get_cost() >= 0)
            self.assertTrue(route_a.get_cost() < 10000)
        
        for i in range(100):
            route_a.rand_cost_poly(3, 0, 4.641)
            self.assertTrue(route_a.get_cost() >= 0)
            self.assertTrue(route_a.get_cost() < 100)
        
    def test_actor_cost(self):
        route_a = route.Route()
        ints = [0, -15, 3, 5, 6]
        cost = 0
        for i in ints:
            route_a.actor_set_cost(i, cost)
            cost = cost + 1
        
        cost = 0
        for i in ints:
            self.assertEquals(cost, route_a.actor_get_cost(i))
            cost = cost + 1
            


if __name__ == '__main__':
    unittest.main()
    
def get_suite():
    return unittest.makeSuite(RouteTest)
